<!--
* description: 车型配置（含弹窗）
* author: zhhx
* createdDate: 2019-08-08
-->

<template>
  <section class="cartypeInp">
    <el-col :span="span">
      <lableName
        :cur-label-name="curLabelName"
        :is-show-label="isShowLabel"
        :is-require="isRequire"
      />
      <el-input
        v-model="modelCode"
        :placeholder="placeholder"
        size="small"
        suffix-icon="el-icon-s-unfold"
        clearable
        readonly
        @blur="sendCode"
        @focus="getFocusCode"
        @clear="clearCode"
      />
      <validateFormate
        :cur-label-name="curLabelName"
        :validrule="validrule"
      />
    </el-col>
    <carTypeConfig
      :key="curPopupsKey"
      ref="carType"
      :popups-visible.sync="curPopupsVisible"
      :code-field="codeField"
      :com-type="comType"
      :popups-key="popupsKey"
      :code="modelCode"
      :text="modelText"
      :value-object="curValueObject"
      :is-mul="isMul"
      @changeCode="getComponentCode"
    />
  </section>
</template>
<script>
import { searchInputMixins } from '@/components/mixins/searchInputMixins'
import { valueObjectMixins } from '@/components/mixins/valueObjectMixins'

import carTypeConfig from './experienceCenter'
export default {
  name: 'ExperienceCenterInput',
  components: {
    carTypeConfig,
    lableName: () => import('@/components/lableName'), // 标题溢出样式组件
    validateFormate: () => import('@/components/validateFormate') // 校验提示样式组件
  },
  // 组件混入对象
  mixins: [searchInputMixins, valueObjectMixins],
  data() {
    return {
      editPageClassName: 'testDriver',
      editEl: null,
      curPopupsVisible: false,
      placeholder: '选择体验中心',
      curLabelName: this.labelName === '' ? '体验中心' : this.labelName
    }
  },
  watch: {
    modelCode(val) {
      // if(this.editEl===null) this.foundEl(this.editPageClassName)
      // this.editEl.formField[this.codeField] = val
      // this.$parent.$parent.$parent.formField[this.codeField] = val
      this.$emit('changeCode', val, this.modelText, this.codeField, this.comType, this.popupsKey, this.textField, null, null)
    }
  },
  methods: {
    // foundEl(className,parent=this.$parent){
    //   let el_classname = parent.$el['className']
    //   el_classname === className ? this.editEl = parent : this.foundEl(className,parent.$parent)
    // },
    getFocusCode() {
      this.curPopupsVisible = true
      this.$nextTick(() => {
        // 加载dialog中的数据
        this.$refs['carType'].queryTable(1)
      })
    }

  }
}
</script>
